package com.minhua.jijiehao2.mainframe.mine.productListActivity.impl

import android.support.v4.app.Fragment
import android.support.v4.app.FragmentPagerAdapter
import android.view.View
import com.minhua.jijiehao2.R
import com.minhua.jijiehao2.base.BaseActivity
import com.minhua.jijiehao2.mainframe.mine.productListActivity.imp.IProductListView
import com.minhua.jijiehao2.mainframe.mine.productListFragment.impl.ProductListFragment
import kotlinx.android.synthetic.main.activity_product_list.*

class ProductListActivity : BaseActivity<IProductListView, ProductListPresenter>(), IProductListView {

    override fun getLayoutId(): Int = R.layout.activity_product_list

    override fun getPresenter(): ProductListPresenter = ProductListPresenter()

    private val mOnClickListener = View.OnClickListener { v ->
        when (v.id) {
            else -> {
            }
        }
    }

    private val fragments = arrayListOf<ProductListFragment>()
    private val titles = listOf("已上架产品", "待审核产品", "审核未通过")
    override fun initView() {
        fragments.add(ProductListFragment.newInstance(1))
        fragments.add(ProductListFragment.newInstance(2))
        fragments.add(ProductListFragment.newInstance(3))
        tlTab.setupWithViewPager(vpContent)
        vpContent.offscreenPageLimit = 2
        vpContent.adapter = object : FragmentPagerAdapter(supportFragmentManager) {
            override fun getCount(): Int = fragments.size

            override fun getItem(position: Int): Fragment = fragments[position]

            override fun getPageTitle(position: Int): CharSequence = titles[position]
        }
    }


}
